﻿using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using Microsoft.Cis.E2E.COMMON;

namespace HWCWorker_Worker
{
    internal class LogClient
    {
        private string Tag { get; set; }
        private TcpLogger WorkerMon { get; set; }
        private LocalLogger _logger;

        public LogClient(string clientTag)
        {
            Tag = clientTag;
            _logger = new LocalLogger();
            SetServer("WorkerMon");
        }

        private void SetServer(string TargetRole)
        {
            WorkerMon = new TcpLogger(TargetRole);
        }

        public void Log(string fmt, params object[] arg)
        {
            string msg = string.Format(fmt, arg);
            try
            {
                WorkerMon.PutLog(Tag, msg);
            }
            catch (Exception e)
            {
                //TODO:put failed content to Nephos Blob
                System.Diagnostics.Debug.WriteLine("Progress.Report:" + e.Message);
                _logger.Log(Tag, "Progress.Report:" + e.Message);
                _logger.Log(Tag, "alt:" + msg);
            }
        }

    }
}